package com.kevin.sportplay.controller;

import com.alibaba.fastjson.JSON;
import com.kevin.sportplay.bean.MainMenu;
import com.kevin.sportplay.dao.MenuDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.*;
import java.util.HashMap;
import java.util.List;


/**
 * @author KevinYE
 * @creat 2021-08-07-16:40
 */
@RestController
public class MenuController {
    @Autowired
    MenuDao menuDao;

    @RequestMapping("/menus")
    public String getAllMenus(){
        List<MainMenu> menus = menuDao.getMenus();
        HashMap<String, Object> reMap = new HashMap<>();
        if(menus != null){

            reMap.put("menus",menus);
            reMap.put("flag",200);
        }else{
            reMap.put("flag",404);
        }


        String jsonString = JSON.toJSONString(reMap);
        return jsonString;
    }

}
